home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr49 / strpp300.zip / STRNG.CPP < prev    next >
C/C++ Source or Header  |  1993-04-11  |  1KB  |  52 lines

  1. /* -------------------------------------------------------------------- */
  2. /* String++ Version 3.00                                       04/10/93 */
  3. /*                                                                      */
  4. /* Enhanced String class for Turbo C++/Borland C++.                     */
  5. /* Copyright 1991, 1992 by Borland International                        */
  6. /*                                                                      */
  7. /* strng.cpp                                                            */
  8. /* -------------------------------------------------------------------- */
  9.  
  10. #ifndef _STRNG_H
  11. #include "Strng.h"
  12. #endif
  13.  
  14. #ifndef __STDLIB_H
  15. #include <stdlib.h>
  16. #endif
  17.  
  18. #ifndef __STRING_H
  19. #include <string.h>
  20. #endif
  21.  
  22. #ifndef __IOSTREAM_H
  23. #include <iostream.h>
  24. #endif
  25.  
  26. String::isEqual(const Object& testString) const
  27. {
  28.   return (strLen == ((String &)testString).strLen &&
  29.           !strcmp(strPtr, ((String &)testString).strPtr));
  30. }
  31.  
  32. int String::isLessThan(const Object& testString) const
  33. {
  34.   return (strcmp(strPtr, ((String &)testString).strPtr) < 0 );
  35. }
  36.  
  37. hashValueType String::hashValue() const
  38. {
  39.   hashValueType value = hashValueType(0);
  40.   for(int i = 0; i < strLen; i++ )
  41.   {
  42.     value ^= strPtr[i];
  43.     value = _rotl(value, 1);
  44.   }
  45.   return value;
  46. }
  47.  
  48. void String::printOn(ostream& outputStream) const
  49. {
  50.   outputStream << strPtr;
  51. }
  52.